from datetime import datetime
from ..db import db
from .base_model import BaseModel
from sqlalchemy import Column, String, DateTime, Integer


class Program(BaseModel, db.Base):
    __tablename__ = 'program_line'

    id: Column = Column(Integer, primary_key=True, autoincrement=True)
    name = Column(String(256), nullable=False)
    title = Column(String(512), nullable=False)
    begin_time = Column(DateTime, nullable=False)
    end_time = Column(DateTime, nullable=False)

    def __init__(self, name: str, title: str, begin_time: datetime, end_time: datetime) -> None:
        self.name = name
        self.title = title
        self.begin_time = begin_time
        self.end_time = end_time

class ProgramType(db.Base, BaseModel):
    __tablename__ = 'program_type'

    id: Column = Column(Integer, primary_key=True, autoincrement=True)
    name = Column(String(256), nullable=False)
    color = Column(String(6), nullable=False)

    def __init__(self, name: str, color: str) -> None:
        self.name = name
        self.color = color
